﻿#pragma once
#define _CRT_SECURE_NO_WARNINGS 1
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cassert>

namespace th
{
	const size_t EXPANSION_FACTOR = 2;
	const size_t INITIAL_CAPACITY = 8;
	class string
	{
	public:
		string(const char* str = "");

		string(const string&);
		string& operator=(string&);
		char* begin() const;
		char* end() const;
		char* begin();
		char* end();
		char& operator[](int index);
		~string();

		void insert(int index, char ch);
		void reserve(size_t n);
		void append(const char* str);
		void append(const char ch);
		string& operator+=(const char* str);
		string& operator+=(const char ch);
		void push_back(char ch);
		void erase(size_t pos, size_t len);
	private:
		size_t _size;
		size_t _capacity;
		char* _str;
	};


	std::ostream& operator<<(std::ostream& out, const th::string& str);
}